$(function(){
	function home_resize(){
		var $win = $(window),
			$head = $('header'),
			$foot = $('footer'),
			minHeight = 500,
			newHeight = $win.height() - ($head.height() - 2) - $foot.height();
	
		$('#home-content,#home-content>div').css({
			height: (newHeight > minHeight ? newHeight : minHeight)
		});
	
	}
	
	home_resize();
	
	$(window).resize(home_resize);
	
	var $captions = $('#captions').bxSlider({
		mode: 'vertical',
		easing: 'easeOutBack',
		speed: 1000,
		pager: false,
		controls: false,
		auto: false,
		wrapperClass: 'captions'
	});
	$('#home-content>div').bxSlider({
		mode: 'fade', 
		speed: 1000, 
		pager: true,
		pagerSelector: '#bx-pager',
		captions: true, 
		auto: true, 
		controls:false, 
		autoHover: true, 
		randomStart: false,
		onBeforeSlide: function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject){
			$captions.goToSlide(currentSlideNumber);
		}
	});
	$('.social').find('.facebook>div,.twitter>div,.vimeo>div').hover(function(){
		$(this).animate({opacity:1},200);
	},function(){
		$(this).animate({opacity:0},200);
	});

	$('.product>figure,#dwslider').bxSlider({
		mode: 'horizontal', 
		speed: 1000, 
		pager: true, 
		auto: true, 
		controls:false, 
		autoHover: true, 
		randomStart: true
	});
	$('.related-product li,.product-list li,.news li').hover(function(){
		$('.title', this).css({'color':'#FF42A8'});
		$('.readmore', this).css({'borderBottom':'2px solid #FF42A8'});
	},function(){
		$('.title', this).css({'color':'#000000'});
		$('.readmore', this).css({'borderBottom':'1px solid #818181'});
	});
	$('.product-list-category a').click(function(e){
		e.preventDefault();
		var $a = $(this);
		$.get(this.href, function(data){
			$('.product-list').fadeOut('fast',function(){
				$('.product-list').replaceWith(data).fadeIn('fast');
				$('.product-list-category a').removeClass('active');
				$a.addClass('active');
			});
		});
	});
});
